const express = require('express')
const app = express()
const cors = require('cors')//cors 跨域模块
const adminRouter = require('./route/admin')


app.use(cors({
    origin:['http://localhost:8080','http://127.0.0.1:5500']//允许这两个地址跨域
}))
app.use(express.urlencoded({
    extended:false
}))

app.use('/login',adminRouter)
app.listen(3000,()=>{
    console.log('Do not shut down the server when it is started...');
})
app.use((err,req,res,next)=>{
    console.log(err);
    res.status(500).send({code:500,msg:'服务器错误!'})
})